import java.util.Arrays;
import java.util.Comparator;

public class Review {
    /*
    public static void main(String[] args) {
        int[][] mat = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
        ZigZagTravel(mat);

    }

    public static void ZigZagTravel(int[][] mat) {
        boolean fromUp = false;
        int tR = 0;
        int tC = 0;
        int dR = 0;
        int dC = 0;
        int endR = mat.length - 1;
        int endC = mat[0].length - 1;
        while (tR <= endR && tC <= endC) {
            process(mat, tR, tC, dR, dC, fromUp);
            tR = tC == endC ? tR + 1 : tR;
            tC = tC == endC ? tC : tC + 1;
            dC = dR == endR ? dC + 1 : dC;
            dR = dR == endR ? dR : dR + 1;
            fromUp = !fromUp;
        }
    }

    public static void process(int[][] mat, int tR, int tC, int dR, int dC, boolean fromUp) {
        if (fromUp) {
            while (tR != dR + 1) {
                System.out.print(" " + mat[tR++][tC--]);
            }
        } else {
            while (dR != tR - 1) {
                System.out.print(" " + mat[dR--][dC++]);
            }
        }
    }
     */

    /*
    public static void main(String[] args) {
        int[][] mat = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
        int tR = 0;
        int tC = 0;
        int dR = mat.length - 1;
        int dC = mat[0].length - 1;
        while (tR <= dR && tC <= dC) {
            process(mat, tR++, tC++, dR--, dC--);
        }
    }

    public static void process(int[][] mat, int tR, int tC, int dR, int dC) {
        if (tR == dR) {
            for (int i = tC; i <= dC; i++) {
                System.out.print(" " + mat[tR][i]);
            }
        } else if (tC == dC) {
            for (int i = tR; i <= dR; i++) {
                System.out.print(" " + mat[i][tC]);
            }
        } else {
            int curC = tC;
            int curR =tR;
            while (curC != dC) {
                System.out.print(" " + mat[tC][curC]);
                curC++;
            }
            while (curR != dR) {
                System.out.print(" " + mat[curR][dC]);
                curR++;
            }
            while (curC != tC) {
                System.out.print(" " + mat[dR][curC]);
                curC--;
            }
            while (curR != tR) {
                System.out.print(" " + mat[curR][tC]);
                curR--;
            }
        }
    }
     */

    /*
    public static void main(String[] args) {
        int[][] mat = {{1,2,3},{4,5,6},{7,8,9}};
        int a = 0;
        int b = 0;
        int c = mat.length - 1;
        int d = mat[0].length - 1;
        while (a < c) {
            rorate(mat, a++, b++, c--, d--);
        }
        for (int[] i : mat) {
            System.out.println(Arrays.toString(i));
        }
    }

    public static void rorate(int[][] mat, int a, int b, int c, int d) {
        int temp = 0;
        for (int i = 0; i < d - b; i++) {
            temp = mat[a][b + i];
            mat[a][b + i] = mat[c - i][b];
            mat[c - i][b] = mat[c][d - i];
            mat[c][d - i] = mat[a + i][d];
            mat[a + i][d] = temp;
        }
    }

     */

    /*
    public static void main(String[] args) {
        int n = 4;
        int index = 1;
        int left = 0;
        int right = n - 1;
        int up = 0;
        int down = n - 1;
        int mat[][] = new int[n][n];
        while (index <= n * n) {
            for (int i = left; i<= right; i++) {
                mat[up][i] = index++;
            }
            up++;
            for (int i = up; i <= down; i++) {
                mat[i][right] = index++;
            }
            right--;
            for (int i = right; i >= left; i--) {
                mat[down][i] = index++;
            }
            down--;
            for (int i = down; i >= up; i--) {
                mat[i][left] = index++;
            }
            left++;
        }
        for (int[] i : mat) {
            System.out.println(Arrays.toString(i));
        }
    }
     */

    public static void main(String[] args) {
        String[] str = {"xxz", "abba", "baba", "cdae"};
        String res = "";
        Arrays.sort(str, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.compareTo(o2);
            }
        });
        for (int i = 0; i < str.length; i++) {
            res += str[i];
        }
        System.out.println(res);
    }
}
